We can pass data from child to parent using a callback function passed as a prop from parent to children, this callback will be called to update parent with the data in child component.
lifting state up to a common ancestor
using a state management library like Redux, mobx
Use context api
employing a state management pattern like prop drilling.
In this example, when the button in ChildComponentA is clicked, the sendData method is called, which in turn calls the handleData method of ParentComponent (passed down as a prop), updating the state of ParentComponent with the data from ChildComponentA. This updated state is then passed to ChildComponentB as a prop.
This is a simple example, and there are other ways to share data among sibling components, such as using context or third-party state management libraries like Redux or MobX, depending on the complexity of your application